export default {
  marshalParams(e) {
    // 将查询参数没有传参的字段去除
    let values = Object.values(e);
    let keys = Object.keys(e);
    values.forEach((item, index) => {
      if(item === ''|| item === ' ') {
        delete e[keys[index]];
      }
    });
    return e;
  },
  timeLeftCalc(time) {
    // 剩余结案时间计算
    let hour, min, timeLeft;
    hour = parseInt(Math.abs(time) / 3600);
    min = parseInt((Math.abs(time) % 3600) / 60);
    timeLeft = [hour, '小时', min, '分'].join('')
    return timeLeft;
  },
  varifyParams(action, params) {
    // 校验表单数据
    let n = 0;
    switch (action) {
      case 'deal':
        params.other.formValue.forEach( item => {
          if (item[item.name] === undefined) {
            n += 1;
          }
        });
        break;
      case 'new':
        params.formValue.forEach( item => {
          if (item[item.name] === undefined) {
            n += 1;
          }
        });
        break;
      default:
        Object.keys(params).forEach( item => {
          if (params[item] == '') {
            n += 1;
          }
        });
        break;
    };
    if (n === 0) {
      return true;
    } else {
      return false;
    };
  }
}